package com.example.liwushuo.fragment;


import android.os.Bundle;

import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import com.example.liwushuo.R;
import com.example.liwushuo.adapter.VpiAdapter;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.ArrayList;

/**
 * A simple {@link Fragment} subclass.
 */
public class HomeFragment extends Fragment {

    @ViewInject(R.id.tbi)
    private com.viewpagerindicator.TabPageIndicator tbi;
    @ViewInject(R.id.vp_home)
    private ViewPager vpHome;
    private ArrayList<Fragment> fragments=new ArrayList<>();
    private String[] title={"精选","双11清单","礼物","美食","数码","运动"};
    private VpiAdapter adapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, container, false);
        ViewUtils.inject(this,view);
        initView();
        return view;
    }

    private void initView() {
        fragments.add(new SelectFragment());
        fragments.add(new SelectFragment());
        fragments.add(new SelectFragment());
        fragments.add(new SelectFragment());
        fragments.add(new SelectFragment());
        fragments.add(new SelectFragment());
        adapter = new VpiAdapter(getChildFragmentManager(),fragments,title);
        vpHome.setAdapter(adapter);
        tbi.setViewPager(vpHome);

    }


}
